<template>
  <div v-show="showBanner">
    <div class="banner" @click="handleBannerClick">
      <img class="banner-img" :src="listObject.bannerImg" />
      <div class="banner-info">
        <div class="banner-tittle">{{listObject.sightName}}</div>
        <div class="banner-number">
          <span class="iconfont">&#xe625;</span>
          <span class="banner-count">{{showBanner}}</span>
        </div>
      </div>
    </div>
    <div class="detail-comment border-bottom">
      <div class="detail-left">
        <div>
          <div class="left-top">
            <span style="font-size: .48rem;">{{listObject.score}}</span>
            <span>分&nbsp;&nbsp;{{listObject.score_desc}}</span>
          </div>
          <div class="comment-counts">{{listObject.comments}}条评论</div>
        </div>
        <div class="iconfont icon-size">&#xe6ab;</div>
      </div>
      <div class="detail-left border-left">
        <div>
          <div>景点简介</div>
          <div class="comment-counts" style="margin-top: .2rem;">开放时间、贴士</div>
        </div>
        <div class="iconfont icon-size">&#xe6ab;</div>
      </div>
    </div>
    <div class="detail-position">
      <span class="iconfont position-icon">&#xe611;</span>
      <span>{{listObject.position}}</span>
    </div>
    <div class="message-item" v-show="listObject.message">
      <div class="detail-message">
        <span class="iconfont">&#xe689;</span>
        <span>{{listObject.message}}</span>
      </div>
      <div>
        <span class="iconfont message-icon">&#xe6ab;</span>
      </div>
    </div>
    <fade-animation>
      <common-gallary
        @close="handleGallaryClose"
        :imgs="listObject.gallaryImgs"
        v-show="showGallary"
      ></common-gallary>
    </fade-animation>
  </div>
</template>

<script>
import CommonGallary from 'common/gallary/Gallary'
import FadeAnimation from 'common/fade/FadeAnimation'
export default {
  name: 'DetailBanner',
  props: {
    listObject: Object
    // gallaryImgs: Array
  },
  components: {
    CommonGallary,
    FadeAnimation
  },
  data() {
    return {
      imgs: [
        'http://img1.qunarzz.com/sight/p0/1502/6b/6b079eb07e4b38c9.water.jpg_r_800x800_42c5fbab.jpg'
      ],
      showGallary: false
      // listObject: {}
    }
  },
  mounted() {
    // this.listObject =
  },
  methods: {
    // 显示画廊
    handleBannerClick() {
      this.showGallary = true
    },
    // 隐藏画廊
    handleGallaryClose() {
      this.showGallary = false
    }
  },
  computed: {
    showBanner() {
      // return this.listObject.gallaryImgs.length
      if (JSON.stringify(this.listObject) === '{}') {
        return false
      } else return this.listObject.gallaryImgs.length
    }
  }
}
</script>
<style scoped lang="stylus">
@import '~styles/mixins.styl';

.border-left {
  &:before {
    border-color: #e0e0e0;
  }
}

.border-bottom {
  &:before {
    border-color: #e0e0e0;
  }
}

.banner {
  position: relative;
  overflow: hidden;
  height: 0;
  padding-bottom: 55%;

  .banner-img {
    width: 100%;
    height: 4.6rem;
  }

  .banner-info {
    display: flex;
    position: absolute;
    align-items: center;
    left: 0;
    right: 0;
    bottom: 0;
    line-height: 1.2rem;
    padding: 0 0.2rem;
    color: #fff;
    background-image: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));

    .banner-tittle {
      flex: 1;
      font-size: 0.36rem;
      font-weight: bold;
    }

    .banner-number {
      padding: 0 0.4rem;
      height: 0.42rem;
      line-height: 0.42rem;
      border-radius: 0.2rem;
      background: rgba(0, 0, 0, 0.5);
      font-size: 0.26rem;

      .banner-count {
        display: inline-block;
        margin-left: 0.05rem;
      }
    }
  }
}

.detail-comment {
  overflow: hidden;
  position: relative;
  top: -0.1rem;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: 1.28rem;
  background: #fff;
  border-radius: 0.2rem 0.2rem 0 0;

  .detail-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 50%;
    padding: 0rem 0.2rem;
    // background: green;
    margin: 0.2rem 0;

    .left-top {
      color: #FF7F50;
    }

    .comment-counts {
      display: inline-block;
      margin: 0.1rem 0;
      color: #9e9e9e;
      font-size: 0.26rem;
    }

    .icon-size {
      // font-size: 0.48rem;
      color: #9e9e9e;
    }
  }
}

.detail-position {
  padding: 0.1rem 0.3rem 0.2rem 0.3rem;
  border-bottom: 0.18rem solid #F5F5F5;

  .position-icon {
    display: inline-block;
    padding-right: 0.2rem;
  }
}

.message-item {
  display: flex;
  align-items: center;
  padding: 0.3rem 0.2rem 0.3rem 0.3rem;
  border-bottom: 0.18rem solid #F5F5F5;
  background: #fff5e5;

  .detail-message {
    color: #ff8300;
    ellipsis();
  }

  .message-icon {
    color: #9e9e9e;
  }
}
</style>
